package teacher.action;

import java.text.SimpleDateFormat;
import java.util.Date;

import teacher.bean.Award;
import teacher.bean.Flow;
import teacher.bean.Project;
import teacher.service.flow;
import teacher.service.project;

import com.opensymphony.xwork2.ActionSupport;

public class modifyPro extends ActionSupport{
	private Project pro;
	private int projectId;

	public Project getPro() {
		return pro;
	}

	public void setPro(Project pro) {
		this.pro = pro;
	}

	public int getProjectId() {
		return projectId;
	}

	public void setProjectId(int projectId) {
		this.projectId = projectId;
	}

	public String execute(){
		
		pro=new project().selectProjectById(projectId);
		
//		流程管理部分
		Project a=new Project();
		a=new flow().selectProjectByName(this.getPro().getName());
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Flow f=new Flow();
		f.setFruitId(a.getProId());
		f.setFruitKind(4);
		f.setDirDo(2);
		f.setDirTime(df.format(new Date()));
		f.setSubDo(2);
		f.setSubTime(df.format(new Date()));
		f.setTeaDo(3);
		f.setTeaTime(df.format(new Date()));
//		流程管理结束
		if(new flow().insertFlow(f)){
			if(pro.getKind()==0){
				return SUCCESS;
				}else{
					return ERROR;
				}
		}else{
			if(pro.getKind()==0){
				return SUCCESS;
				}else{
					return ERROR;
				}
		}
		
	} 

}
